package com.example.demo.common;

import com.example.demo.model.AjaxResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;


/**
 * @ClassName：GlobalExceptionHandler
 * @Author: admin
 * @Date: 2024/11/28 15:43
 * @Description: 全局异常处理
 */

@Slf4j
@RestControllerAdvice
public class GlobalExceptionHandler {


    @ExceptionHandler(CustomException.class)
    public AjaxResult generalBusinessExceptionHandler(CustomException ex)
    {
        log.error("出现异常", ex);
        return AjaxResult.error(ex.getMessage(), ex);
    }
}
